// $ANTLR 3.1.2 F:\\Work\\Graph2\\Grammar\\graph2.g 2009-06-07 18:06:20


using System.Text;


using System;
using Antlr.Runtime;
using IList 		= System.Collections.IList;
using ArrayList 	= System.Collections.ArrayList;
using Stack 		= Antlr.Runtime.Collections.StackList;



using Antlr.Runtime.Tree;

public class graph2Parser : Parser 
{
    public static readonly string[] tokenNames = new string[] 
	{
        "<invalid>", 
		"<EOR>", 
		"<DOWN>", 
		"<UP>", 
		"PARAM", 
		"NEGATE", 
		"PLUS", 
		"MINUS", 
		"MULT", 
		"DIV", 
		"MOD", 
		"INTEGER", 
		"FLOAT", 
		"IDENT", 
		"POW", 
		"'('", 
		"','", 
		"')'", 
		"'['", 
		"']'"
    };

    public const int INTEGER = 11;
    public const int MOD = 10;
    public const int NEGATE = 5;
    public const int PARAM = 4;
    public const int FLOAT = 12;
    public const int MINUS = 7;
    public const int MULT = 8;
    public const int EOF = -1;
    public const int T__19 = 19;
    public const int T__16 = 16;
    public const int T__15 = 15;
    public const int POW = 14;
    public const int T__18 = 18;
    public const int T__17 = 17;
    public const int IDENT = 13;
    public const int PLUS = 6;
    public const int DIV = 9;

    // delegates
    // delegators



        public graph2Parser(ITokenStream input)
    		: this(input, new RecognizerSharedState()) {
        }

        public graph2Parser(ITokenStream input, RecognizerSharedState state)
    		: base(input, state) {
            InitializeCyclicDFAs();

             
       }
        
    protected ITreeAdaptor adaptor = new CommonTreeAdaptor();

    public ITreeAdaptor TreeAdaptor
    {
        get { return this.adaptor; }
        set {
    	this.adaptor = value;
    	}
    }

    override public string[] TokenNames {
		get { return graph2Parser.tokenNames; }
    }

    override public string GrammarFileName {
		get { return "F:\\Work\\Graph2\\Grammar\\graph2.g"; }
    }


    ArrayList exceptions = new ArrayList();

    public override void ReportError(RecognitionException e)
    {
        exceptions.Add(e);
    }

    public bool HasError
    {
    	get { return exceptions.Count > 0; }
    }

    public string ErrorMessage
    {
    	get { return this.GetErrorMessage(exceptions[0] as RecognitionException, this.TokenNames); }
    }

    public string ErrorPosition
    {
    	get { return this.GetErrorHeader(exceptions[0] as RecognitionException); }
    }


    public class function_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "function"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:56:1: function : IDENT '(' ( additiveExpression ( ',' additiveExpression )* )? ')' -> ^( IDENT ( additiveExpression )* ) ;
    public graph2Parser.function_return function() // throws RecognitionException [1]
    {   
        graph2Parser.function_return retval = new graph2Parser.function_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken IDENT1 = null;
        IToken char_literal2 = null;
        IToken char_literal4 = null;
        IToken char_literal6 = null;
        graph2Parser.additiveExpression_return additiveExpression3 = null;

        graph2Parser.additiveExpression_return additiveExpression5 = null;


        CommonTree IDENT1_tree=null;
        CommonTree char_literal2_tree=null;
        CommonTree char_literal4_tree=null;
        CommonTree char_literal6_tree=null;
        RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor,"token IDENT");
        RewriteRuleTokenStream stream_17 = new RewriteRuleTokenStream(adaptor,"token 17");
        RewriteRuleTokenStream stream_15 = new RewriteRuleTokenStream(adaptor,"token 15");
        RewriteRuleTokenStream stream_16 = new RewriteRuleTokenStream(adaptor,"token 16");
        RewriteRuleSubtreeStream stream_additiveExpression = new RewriteRuleSubtreeStream(adaptor,"rule additiveExpression");
        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:57:2: ( IDENT '(' ( additiveExpression ( ',' additiveExpression )* )? ')' -> ^( IDENT ( additiveExpression )* ) )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:57:4: IDENT '(' ( additiveExpression ( ',' additiveExpression )* )? ')'
            {
            	IDENT1=(IToken)Match(input,IDENT,FOLLOW_IDENT_in_function134);  
            	stream_IDENT.Add(IDENT1);

            	char_literal2=(IToken)Match(input,15,FOLLOW_15_in_function136);  
            	stream_15.Add(char_literal2);

            	// F:\\Work\\Graph2\\Grammar\\graph2.g:57:14: ( additiveExpression ( ',' additiveExpression )* )?
            	int alt2 = 2;
            	int LA2_0 = input.LA(1);

            	if ( (LA2_0 == MINUS || (LA2_0 >= INTEGER && LA2_0 <= IDENT) || LA2_0 == 15 || LA2_0 == 18) )
            	{
            	    alt2 = 1;
            	}
            	switch (alt2) 
            	{
            	    case 1 :
            	        // F:\\Work\\Graph2\\Grammar\\graph2.g:57:16: additiveExpression ( ',' additiveExpression )*
            	        {
            	        	PushFollow(FOLLOW_additiveExpression_in_function140);
            	        	additiveExpression3 = additiveExpression();
            	        	state.followingStackPointer--;

            	        	stream_additiveExpression.Add(additiveExpression3.Tree);
            	        	// F:\\Work\\Graph2\\Grammar\\graph2.g:57:35: ( ',' additiveExpression )*
            	        	do 
            	        	{
            	        	    int alt1 = 2;
            	        	    int LA1_0 = input.LA(1);

            	        	    if ( (LA1_0 == 16) )
            	        	    {
            	        	        alt1 = 1;
            	        	    }


            	        	    switch (alt1) 
            	        		{
            	        			case 1 :
            	        			    // F:\\Work\\Graph2\\Grammar\\graph2.g:57:36: ',' additiveExpression
            	        			    {
            	        			    	char_literal4=(IToken)Match(input,16,FOLLOW_16_in_function143);  
            	        			    	stream_16.Add(char_literal4);

            	        			    	PushFollow(FOLLOW_additiveExpression_in_function145);
            	        			    	additiveExpression5 = additiveExpression();
            	        			    	state.followingStackPointer--;

            	        			    	stream_additiveExpression.Add(additiveExpression5.Tree);

            	        			    }
            	        			    break;

            	        			default:
            	        			    goto loop1;
            	        	    }
            	        	} while (true);

            	        	loop1:
            	        		;	// Stops C# compiler whining that label 'loop1' has no statements


            	        }
            	        break;

            	}

            	char_literal6=(IToken)Match(input,17,FOLLOW_17_in_function152);  
            	stream_17.Add(char_literal6);



            	// AST REWRITE
            	// elements:          IDENT, additiveExpression
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 57:68: -> ^( IDENT ( additiveExpression )* )
            	{
            	    // F:\\Work\\Graph2\\Grammar\\graph2.g:57:71: ^( IDENT ( additiveExpression )* )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot(stream_IDENT.NextNode(), root_1);

            	    // F:\\Work\\Graph2\\Grammar\\graph2.g:57:79: ( additiveExpression )*
            	    while ( stream_additiveExpression.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_additiveExpression.NextTree());

            	    }
            	    stream_additiveExpression.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "function"

    public class expression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "expression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:65:1: expression : additiveExpression EOF ;
    public graph2Parser.expression_return expression() // throws RecognitionException [1]
    {   
        graph2Parser.expression_return retval = new graph2Parser.expression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken EOF8 = null;
        graph2Parser.additiveExpression_return additiveExpression7 = null;


        CommonTree EOF8_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:66:2: ( additiveExpression EOF )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:66:5: additiveExpression EOF
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_additiveExpression_in_expression228);
            	additiveExpression7 = additiveExpression();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, additiveExpression7.Tree);
            	EOF8=(IToken)Match(input,EOF,FOLLOW_EOF_in_expression230); 

            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "expression"

    public class additiveExpression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "additiveExpression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:69:1: additiveExpression : multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )* ;
    public graph2Parser.additiveExpression_return additiveExpression() // throws RecognitionException [1]
    {   
        graph2Parser.additiveExpression_return retval = new graph2Parser.additiveExpression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken set10 = null;
        graph2Parser.multiplicativeExpression_return multiplicativeExpression9 = null;

        graph2Parser.multiplicativeExpression_return multiplicativeExpression11 = null;


        CommonTree set10_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:70:2: ( multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )* )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:70:4: multiplicativeExpression ( ( PLUS | MINUS ) multiplicativeExpression )*
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression244);
            	multiplicativeExpression9 = multiplicativeExpression();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, multiplicativeExpression9.Tree);
            	// F:\\Work\\Graph2\\Grammar\\graph2.g:70:29: ( ( PLUS | MINUS ) multiplicativeExpression )*
            	do 
            	{
            	    int alt3 = 2;
            	    int LA3_0 = input.LA(1);

            	    if ( ((LA3_0 >= PLUS && LA3_0 <= MINUS)) )
            	    {
            	        alt3 = 1;
            	    }


            	    switch (alt3) 
            		{
            			case 1 :
            			    // F:\\Work\\Graph2\\Grammar\\graph2.g:70:31: ( PLUS | MINUS ) multiplicativeExpression
            			    {
            			    	set10=(IToken)input.LT(1);
            			    	set10 = (IToken)input.LT(1);
            			    	if ( (input.LA(1) >= PLUS && input.LA(1) <= MINUS) ) 
            			    	{
            			    	    input.Consume();
            			    	    root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set10), root_0);
            			    	    state.errorRecovery = false;
            			    	}
            			    	else 
            			    	{
            			    	    MismatchedSetException mse = new MismatchedSetException(null,input);
            			    	    throw mse;
            			    	}

            			    	PushFollow(FOLLOW_multiplicativeExpression_in_additiveExpression255);
            			    	multiplicativeExpression11 = multiplicativeExpression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, multiplicativeExpression11.Tree);

            			    }
            			    break;

            			default:
            			    goto loop3;
            	    }
            	} while (true);

            	loop3:
            		;	// Stops C# compiler whining that label 'loop3' has no statements


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "additiveExpression"

    public class multiplicativeExpression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "multiplicativeExpression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:73:1: multiplicativeExpression : powerExpression ( ( MULT | DIV | MOD ) powerExpression )* ;
    public graph2Parser.multiplicativeExpression_return multiplicativeExpression() // throws RecognitionException [1]
    {   
        graph2Parser.multiplicativeExpression_return retval = new graph2Parser.multiplicativeExpression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken set13 = null;
        graph2Parser.powerExpression_return powerExpression12 = null;

        graph2Parser.powerExpression_return powerExpression14 = null;


        CommonTree set13_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:74:2: ( powerExpression ( ( MULT | DIV | MOD ) powerExpression )* )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:74:4: powerExpression ( ( MULT | DIV | MOD ) powerExpression )*
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_powerExpression_in_multiplicativeExpression270);
            	powerExpression12 = powerExpression();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, powerExpression12.Tree);
            	// F:\\Work\\Graph2\\Grammar\\graph2.g:74:20: ( ( MULT | DIV | MOD ) powerExpression )*
            	do 
            	{
            	    int alt4 = 2;
            	    int LA4_0 = input.LA(1);

            	    if ( ((LA4_0 >= MULT && LA4_0 <= MOD)) )
            	    {
            	        alt4 = 1;
            	    }


            	    switch (alt4) 
            		{
            			case 1 :
            			    // F:\\Work\\Graph2\\Grammar\\graph2.g:74:22: ( MULT | DIV | MOD ) powerExpression
            			    {
            			    	set13=(IToken)input.LT(1);
            			    	set13 = (IToken)input.LT(1);
            			    	if ( (input.LA(1) >= MULT && input.LA(1) <= MOD) ) 
            			    	{
            			    	    input.Consume();
            			    	    root_0 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(set13), root_0);
            			    	    state.errorRecovery = false;
            			    	}
            			    	else 
            			    	{
            			    	    MismatchedSetException mse = new MismatchedSetException(null,input);
            			    	    throw mse;
            			    	}

            			    	PushFollow(FOLLOW_powerExpression_in_multiplicativeExpression283);
            			    	powerExpression14 = powerExpression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, powerExpression14.Tree);

            			    }
            			    break;

            			default:
            			    goto loop4;
            	    }
            	} while (true);

            	loop4:
            		;	// Stops C# compiler whining that label 'loop4' has no statements


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "multiplicativeExpression"

    public class powerExpression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "powerExpression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:77:1: powerExpression : unaryExpression ( POW unaryExpression )* ;
    public graph2Parser.powerExpression_return powerExpression() // throws RecognitionException [1]
    {   
        graph2Parser.powerExpression_return retval = new graph2Parser.powerExpression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken POW16 = null;
        graph2Parser.unaryExpression_return unaryExpression15 = null;

        graph2Parser.unaryExpression_return unaryExpression17 = null;


        CommonTree POW16_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:78:2: ( unaryExpression ( POW unaryExpression )* )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:78:4: unaryExpression ( POW unaryExpression )*
            {
            	root_0 = (CommonTree)adaptor.GetNilNode();

            	PushFollow(FOLLOW_unaryExpression_in_powerExpression298);
            	unaryExpression15 = unaryExpression();
            	state.followingStackPointer--;

            	adaptor.AddChild(root_0, unaryExpression15.Tree);
            	// F:\\Work\\Graph2\\Grammar\\graph2.g:78:20: ( POW unaryExpression )*
            	do 
            	{
            	    int alt5 = 2;
            	    int LA5_0 = input.LA(1);

            	    if ( (LA5_0 == POW) )
            	    {
            	        alt5 = 1;
            	    }


            	    switch (alt5) 
            		{
            			case 1 :
            			    // F:\\Work\\Graph2\\Grammar\\graph2.g:78:22: POW unaryExpression
            			    {
            			    	POW16=(IToken)Match(input,POW,FOLLOW_POW_in_powerExpression302); 
            			    		POW16_tree = (CommonTree)adaptor.Create(POW16);
            			    		root_0 = (CommonTree)adaptor.BecomeRoot(POW16_tree, root_0);

            			    	PushFollow(FOLLOW_unaryExpression_in_powerExpression305);
            			    	unaryExpression17 = unaryExpression();
            			    	state.followingStackPointer--;

            			    	adaptor.AddChild(root_0, unaryExpression17.Tree);

            			    }
            			    break;

            			default:
            			    goto loop5;
            	    }
            	} while (true);

            	loop5:
            		;	// Stops C# compiler whining that label 'loop5' has no statements


            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "powerExpression"

    public class unaryExpression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "unaryExpression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:81:1: unaryExpression : ( primaryExpression | MINUS primaryExpression -> ^( NEGATE primaryExpression ) );
    public graph2Parser.unaryExpression_return unaryExpression() // throws RecognitionException [1]
    {   
        graph2Parser.unaryExpression_return retval = new graph2Parser.unaryExpression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken MINUS19 = null;
        graph2Parser.primaryExpression_return primaryExpression18 = null;

        graph2Parser.primaryExpression_return primaryExpression20 = null;


        CommonTree MINUS19_tree=null;
        RewriteRuleTokenStream stream_MINUS = new RewriteRuleTokenStream(adaptor,"token MINUS");
        RewriteRuleSubtreeStream stream_primaryExpression = new RewriteRuleSubtreeStream(adaptor,"rule primaryExpression");
        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:82:2: ( primaryExpression | MINUS primaryExpression -> ^( NEGATE primaryExpression ) )
            int alt6 = 2;
            int LA6_0 = input.LA(1);

            if ( ((LA6_0 >= INTEGER && LA6_0 <= IDENT) || LA6_0 == 15 || LA6_0 == 18) )
            {
                alt6 = 1;
            }
            else if ( (LA6_0 == MINUS) )
            {
                alt6 = 2;
            }
            else 
            {
                NoViableAltException nvae_d6s0 =
                    new NoViableAltException("", 6, 0, input);

                throw nvae_d6s0;
            }
            switch (alt6) 
            {
                case 1 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:82:4: primaryExpression
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_primaryExpression_in_unaryExpression320);
                    	primaryExpression18 = primaryExpression();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, primaryExpression18.Tree);

                    }
                    break;
                case 2 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:83:8: MINUS primaryExpression
                    {
                    	MINUS19=(IToken)Match(input,MINUS,FOLLOW_MINUS_in_unaryExpression329);  
                    	stream_MINUS.Add(MINUS19);

                    	PushFollow(FOLLOW_primaryExpression_in_unaryExpression331);
                    	primaryExpression20 = primaryExpression();
                    	state.followingStackPointer--;

                    	stream_primaryExpression.Add(primaryExpression20.Tree);


                    	// AST REWRITE
                    	// elements:          primaryExpression
                    	// token labels:      
                    	// rule labels:       retval
                    	// token list labels: 
                    	// rule list labels:  
                    	// wildcard labels: 
                    	retval.Tree = root_0;
                    	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

                    	root_0 = (CommonTree)adaptor.GetNilNode();
                    	// 83:32: -> ^( NEGATE primaryExpression )
                    	{
                    	    // F:\\Work\\Graph2\\Grammar\\graph2.g:83:35: ^( NEGATE primaryExpression )
                    	    {
                    	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
                    	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(NEGATE, "NEGATE"), root_1);

                    	    adaptor.AddChild(root_1, stream_primaryExpression.NextTree());

                    	    adaptor.AddChild(root_0, root_1);
                    	    }

                    	}

                    	retval.Tree = root_0;retval.Tree = root_0;
                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "unaryExpression"

    public class primaryExpression_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "primaryExpression"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:86:1: primaryExpression : ( '(' additiveExpression ')' | value );
    public graph2Parser.primaryExpression_return primaryExpression() // throws RecognitionException [1]
    {   
        graph2Parser.primaryExpression_return retval = new graph2Parser.primaryExpression_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken char_literal21 = null;
        IToken char_literal23 = null;
        graph2Parser.additiveExpression_return additiveExpression22 = null;

        graph2Parser.value_return value24 = null;


        CommonTree char_literal21_tree=null;
        CommonTree char_literal23_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:87:2: ( '(' additiveExpression ')' | value )
            int alt7 = 2;
            int LA7_0 = input.LA(1);

            if ( (LA7_0 == 15) )
            {
                alt7 = 1;
            }
            else if ( ((LA7_0 >= INTEGER && LA7_0 <= IDENT) || LA7_0 == 18) )
            {
                alt7 = 2;
            }
            else 
            {
                NoViableAltException nvae_d7s0 =
                    new NoViableAltException("", 7, 0, input);

                throw nvae_d7s0;
            }
            switch (alt7) 
            {
                case 1 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:87:4: '(' additiveExpression ')'
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	char_literal21=(IToken)Match(input,15,FOLLOW_15_in_primaryExpression355); 
                    	PushFollow(FOLLOW_additiveExpression_in_primaryExpression358);
                    	additiveExpression22 = additiveExpression();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, additiveExpression22.Tree);
                    	char_literal23=(IToken)Match(input,17,FOLLOW_17_in_primaryExpression360); 

                    }
                    break;
                case 2 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:88:4: value
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_value_in_primaryExpression366);
                    	value24 = value();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, value24.Tree);

                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "primaryExpression"

    public class value_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "value"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:91:1: value : ( INTEGER | FLOAT | function | parameter );
    public graph2Parser.value_return value() // throws RecognitionException [1]
    {   
        graph2Parser.value_return retval = new graph2Parser.value_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken INTEGER25 = null;
        IToken FLOAT26 = null;
        graph2Parser.function_return function27 = null;

        graph2Parser.parameter_return parameter28 = null;


        CommonTree INTEGER25_tree=null;
        CommonTree FLOAT26_tree=null;

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:92:2: ( INTEGER | FLOAT | function | parameter )
            int alt8 = 4;
            switch ( input.LA(1) ) 
            {
            case INTEGER:
            	{
                alt8 = 1;
                }
                break;
            case FLOAT:
            	{
                alt8 = 2;
                }
                break;
            case IDENT:
            	{
                alt8 = 3;
                }
                break;
            case 18:
            	{
                alt8 = 4;
                }
                break;
            	default:
            	    NoViableAltException nvae_d8s0 =
            	        new NoViableAltException("", 8, 0, input);

            	    throw nvae_d8s0;
            }

            switch (alt8) 
            {
                case 1 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:92:5: INTEGER
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	INTEGER25=(IToken)Match(input,INTEGER,FOLLOW_INTEGER_in_value380); 
                    		INTEGER25_tree = (CommonTree)adaptor.Create(INTEGER25);
                    		adaptor.AddChild(root_0, INTEGER25_tree);


                    }
                    break;
                case 2 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:93:4: FLOAT
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	FLOAT26=(IToken)Match(input,FLOAT,FOLLOW_FLOAT_in_value385); 
                    		FLOAT26_tree = (CommonTree)adaptor.Create(FLOAT26);
                    		adaptor.AddChild(root_0, FLOAT26_tree);


                    }
                    break;
                case 3 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:94:4: function
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_function_in_value390);
                    	function27 = function();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, function27.Tree);

                    }
                    break;
                case 4 :
                    // F:\\Work\\Graph2\\Grammar\\graph2.g:95:4: parameter
                    {
                    	root_0 = (CommonTree)adaptor.GetNilNode();

                    	PushFollow(FOLLOW_parameter_in_value395);
                    	parameter28 = parameter();
                    	state.followingStackPointer--;

                    	adaptor.AddChild(root_0, parameter28.Tree);

                    }
                    break;

            }
            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "value"

    public class parameter_return : ParserRuleReturnScope
    {
        private CommonTree tree;
        override public object Tree
        {
        	get { return tree; }
        	set { tree = (CommonTree) value; }
        }
    };

    // $ANTLR start "parameter"
    // F:\\Work\\Graph2\\Grammar\\graph2.g:98:1: parameter : '[' ( IDENT | INTEGER ) ']' -> ^( PARAM ( IDENT )? ( INTEGER )? ) ;
    public graph2Parser.parameter_return parameter() // throws RecognitionException [1]
    {   
        graph2Parser.parameter_return retval = new graph2Parser.parameter_return();
        retval.Start = input.LT(1);

        CommonTree root_0 = null;

        IToken char_literal29 = null;
        IToken IDENT30 = null;
        IToken INTEGER31 = null;
        IToken char_literal32 = null;

        CommonTree char_literal29_tree=null;
        CommonTree IDENT30_tree=null;
        CommonTree INTEGER31_tree=null;
        CommonTree char_literal32_tree=null;
        RewriteRuleTokenStream stream_INTEGER = new RewriteRuleTokenStream(adaptor,"token INTEGER");
        RewriteRuleTokenStream stream_IDENT = new RewriteRuleTokenStream(adaptor,"token IDENT");
        RewriteRuleTokenStream stream_19 = new RewriteRuleTokenStream(adaptor,"token 19");
        RewriteRuleTokenStream stream_18 = new RewriteRuleTokenStream(adaptor,"token 18");

        try 
    	{
            // F:\\Work\\Graph2\\Grammar\\graph2.g:99:2: ( '[' ( IDENT | INTEGER ) ']' -> ^( PARAM ( IDENT )? ( INTEGER )? ) )
            // F:\\Work\\Graph2\\Grammar\\graph2.g:99:4: '[' ( IDENT | INTEGER ) ']'
            {
            	char_literal29=(IToken)Match(input,18,FOLLOW_18_in_parameter406);  
            	stream_18.Add(char_literal29);

            	// F:\\Work\\Graph2\\Grammar\\graph2.g:99:8: ( IDENT | INTEGER )
            	int alt9 = 2;
            	int LA9_0 = input.LA(1);

            	if ( (LA9_0 == IDENT) )
            	{
            	    alt9 = 1;
            	}
            	else if ( (LA9_0 == INTEGER) )
            	{
            	    alt9 = 2;
            	}
            	else 
            	{
            	    NoViableAltException nvae_d9s0 =
            	        new NoViableAltException("", 9, 0, input);

            	    throw nvae_d9s0;
            	}
            	switch (alt9) 
            	{
            	    case 1 :
            	        // F:\\Work\\Graph2\\Grammar\\graph2.g:99:9: IDENT
            	        {
            	        	IDENT30=(IToken)Match(input,IDENT,FOLLOW_IDENT_in_parameter409);  
            	        	stream_IDENT.Add(IDENT30);


            	        }
            	        break;
            	    case 2 :
            	        // F:\\Work\\Graph2\\Grammar\\graph2.g:99:15: INTEGER
            	        {
            	        	INTEGER31=(IToken)Match(input,INTEGER,FOLLOW_INTEGER_in_parameter411);  
            	        	stream_INTEGER.Add(INTEGER31);


            	        }
            	        break;

            	}

            	char_literal32=(IToken)Match(input,19,FOLLOW_19_in_parameter414);  
            	stream_19.Add(char_literal32);



            	// AST REWRITE
            	// elements:          IDENT, INTEGER
            	// token labels:      
            	// rule labels:       retval
            	// token list labels: 
            	// rule list labels:  
            	// wildcard labels: 
            	retval.Tree = root_0;
            	RewriteRuleSubtreeStream stream_retval = new RewriteRuleSubtreeStream(adaptor, "rule retval", retval!=null ? retval.Tree : null);

            	root_0 = (CommonTree)adaptor.GetNilNode();
            	// 99:28: -> ^( PARAM ( IDENT )? ( INTEGER )? )
            	{
            	    // F:\\Work\\Graph2\\Grammar\\graph2.g:99:31: ^( PARAM ( IDENT )? ( INTEGER )? )
            	    {
            	    CommonTree root_1 = (CommonTree)adaptor.GetNilNode();
            	    root_1 = (CommonTree)adaptor.BecomeRoot((CommonTree)adaptor.Create(PARAM, "PARAM"), root_1);

            	    // F:\\Work\\Graph2\\Grammar\\graph2.g:99:39: ( IDENT )?
            	    if ( stream_IDENT.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_IDENT.NextNode());

            	    }
            	    stream_IDENT.Reset();
            	    // F:\\Work\\Graph2\\Grammar\\graph2.g:99:46: ( INTEGER )?
            	    if ( stream_INTEGER.HasNext() )
            	    {
            	        adaptor.AddChild(root_1, stream_INTEGER.NextNode());

            	    }
            	    stream_INTEGER.Reset();

            	    adaptor.AddChild(root_0, root_1);
            	    }

            	}

            	retval.Tree = root_0;retval.Tree = root_0;
            }

            retval.Stop = input.LT(-1);

            	retval.Tree = (CommonTree)adaptor.RulePostProcessing(root_0);
            	adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);
        }
        catch (RecognitionException re) 
    	{
            ReportError(re);
            Recover(input,re);
    	// Conversion of the second argument necessary, but harmless
    	retval.Tree = (CommonTree)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re);

        }
        finally 
    	{
        }
        return retval;
    }
    // $ANTLR end "parameter"

    // Delegated rules


	private void InitializeCyclicDFAs()
	{
	}

 

    public static readonly BitSet FOLLOW_IDENT_in_function134 = new BitSet(new ulong[]{0x0000000000008000UL});
    public static readonly BitSet FOLLOW_15_in_function136 = new BitSet(new ulong[]{0x000000000006B880UL});
    public static readonly BitSet FOLLOW_additiveExpression_in_function140 = new BitSet(new ulong[]{0x0000000000030000UL});
    public static readonly BitSet FOLLOW_16_in_function143 = new BitSet(new ulong[]{0x000000000004B880UL});
    public static readonly BitSet FOLLOW_additiveExpression_in_function145 = new BitSet(new ulong[]{0x0000000000030000UL});
    public static readonly BitSet FOLLOW_17_in_function152 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_additiveExpression_in_expression228 = new BitSet(new ulong[]{0x0000000000000000UL});
    public static readonly BitSet FOLLOW_EOF_in_expression230 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_multiplicativeExpression_in_additiveExpression244 = new BitSet(new ulong[]{0x00000000000000C2UL});
    public static readonly BitSet FOLLOW_set_in_additiveExpression248 = new BitSet(new ulong[]{0x000000000004B880UL});
    public static readonly BitSet FOLLOW_multiplicativeExpression_in_additiveExpression255 = new BitSet(new ulong[]{0x00000000000000C2UL});
    public static readonly BitSet FOLLOW_powerExpression_in_multiplicativeExpression270 = new BitSet(new ulong[]{0x0000000000000702UL});
    public static readonly BitSet FOLLOW_set_in_multiplicativeExpression274 = new BitSet(new ulong[]{0x000000000004B880UL});
    public static readonly BitSet FOLLOW_powerExpression_in_multiplicativeExpression283 = new BitSet(new ulong[]{0x0000000000000702UL});
    public static readonly BitSet FOLLOW_unaryExpression_in_powerExpression298 = new BitSet(new ulong[]{0x0000000000004002UL});
    public static readonly BitSet FOLLOW_POW_in_powerExpression302 = new BitSet(new ulong[]{0x000000000004B880UL});
    public static readonly BitSet FOLLOW_unaryExpression_in_powerExpression305 = new BitSet(new ulong[]{0x0000000000004002UL});
    public static readonly BitSet FOLLOW_primaryExpression_in_unaryExpression320 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_MINUS_in_unaryExpression329 = new BitSet(new ulong[]{0x000000000004B800UL});
    public static readonly BitSet FOLLOW_primaryExpression_in_unaryExpression331 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_15_in_primaryExpression355 = new BitSet(new ulong[]{0x000000000004B880UL});
    public static readonly BitSet FOLLOW_additiveExpression_in_primaryExpression358 = new BitSet(new ulong[]{0x0000000000020000UL});
    public static readonly BitSet FOLLOW_17_in_primaryExpression360 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_value_in_primaryExpression366 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_INTEGER_in_value380 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_FLOAT_in_value385 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_function_in_value390 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_parameter_in_value395 = new BitSet(new ulong[]{0x0000000000000002UL});
    public static readonly BitSet FOLLOW_18_in_parameter406 = new BitSet(new ulong[]{0x0000000000002800UL});
    public static readonly BitSet FOLLOW_IDENT_in_parameter409 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_INTEGER_in_parameter411 = new BitSet(new ulong[]{0x0000000000080000UL});
    public static readonly BitSet FOLLOW_19_in_parameter414 = new BitSet(new ulong[]{0x0000000000000002UL});

}
